package com.ruoyi.common.core.domain.miniapp;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Sensitive;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.miniapp.dto.MiniAppUserDTO;
import com.ruoyi.common.enums.DesensitizedType;
import lombok.Data;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 小程序用户对象 t_mini_app_user
 * 
 * @author 盖子
 * @date 2024-11-22
 */
@Data
public class MiniAppUser extends BaseEntity implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 编号 */
    private Long id;

    /** 昵称 */
    @Excel(name = "昵称")
    private String nickName;

    /** 真实姓名 */
    @Excel(name = "真实姓名")
    private String realName;

    /** 头像 */
    @Excel(name = "头像")
    private String avatar;

    /** 用户唯一标识 */
    @Excel(name = "用户唯一标识")
    private String openId;

    /** 性别 */
    @Excel(name = "性别")
    private String sex;

    /** 年龄 */
    @Min(value = 1, message = "年龄不能小于 1")
    @Max(value = 150, message = "年龄不能大于 150")
    @Excel(name = "年龄")
    private Long age;

    /** 身高 */
    @PositiveOrZero(message = "身高不能为负数")
    @DecimalMin(value = "30", message = "身高不能低于 30cm")
    @DecimalMax(value = "250", message = "身高不能高于 250cm")
    @Excel(name = "身高")
    private Long height;

    /** 体重 */
    @Digits(integer = 3, fraction = 2, message = "体重格式不正确（最多3位整数+2位小数）")
    @DecimalMin(value = "1.0", message = "体重不能低于 1kg")
    @DecimalMax(value = "600.0", message = "体重不能高于 600kg")
    @Excel(name = "体重")
    private BigDecimal weight;

    /** 归属小程序id */
    @Excel(name = "归属小程序id")
    private Long miniAppId;

    private String miniAppName;

    /** 生日 */
    private String birthday;

    @Sensitive(desensitizedType = DesensitizedType.PHONE)
    private String tel;

    private String address;


    public MiniAppUser()
    {
    }

    public MiniAppUser(Long id, String nickName, String avatar,
                       String openId, String sex, Long miniAppId,
                       Long age,Long height,BigDecimal weight,String tel,
                       String address,String birthday,String realName)
    {
        this.id = id;
        this.nickName = nickName;
        this.realName = realName;
        this.avatar = avatar;
        this.openId = openId;
        this.sex = sex;
        this.miniAppId = miniAppId;
        this.age = age;
        this.height = height;
        this.weight = weight;
        this.tel =tel;
        this.address = address;
        this.birthday = birthday;
    }

    public MiniAppUser(MiniAppUserDTO miniAppUserDTO, Long id)
    {
        this.id = id;
        this.nickName = miniAppUserDTO.getNickName();
        this.realName = miniAppUserDTO.getRealName();
        this.avatar = miniAppUserDTO.getAvatar();
        this.sex = miniAppUserDTO.getSex();
        this.age = miniAppUserDTO.getAge();
        this.height = miniAppUserDTO.getHeight();
        this.weight = miniAppUserDTO.getWeight();
        this.tel =miniAppUserDTO.getTel();
        this.address = miniAppUserDTO.getAddress();
        this.birthday = miniAppUserDTO.getBirthday();
    }
}
